Skip to content

feat(domains): add Vacuum domain (#35)#67

Merged
Faerkeren merged 1 commit into
mainfrom
feature/vacuum-domain
May 26, 2026
Merged

feat(domains): add Vacuum domain (#35)#67
Faerkeren merged 1 commit into
mainfrom
feature/vacuum-domain

Conversation

@Faerkeren

Copy link
Copy Markdown
Contributor

Closes #35.

Issue validity

Valid feature request. The issue identifies a real gap: vacuum entities have no typed domain wrapper, forcing users to make raw service calls and parse attributes by hand. This is inconsistent with the typed coverage already provided for Climate, Media Player, Lock, Valve, etc., and violates the project's core mission of providing a Pythonic abstraction over the HA API. The proposed API also aligns with existing domain conventions (intent-specific actions, structured state properties, listener decorators, graceful capability degradation).

Fix

New src/haclient/domains/vacuum.py defining a Vacuum(Entity) class:

  • State properties: is_cleaning, is_docked, is_idle, is_paused, is_returning, is_error, battery_level, fan_speed, fan_speed_list.
  • Actions: start(), pause(), stop(), return_to_base(), locate(), clean_spot(), set_fan_speed(speed), send_command(command, params=None).
  • Listener decorators: on_start, on_dock, on_error, on_battery_change, on_fan_speed_change.
  • Graceful degradation: every action checks the relevant VacuumEntityFeature bit in supported_features and becomes a debug-logged no-op when unsupported, mirroring the Lock.open / Valve.stop pattern. supports_* properties expose the same checks for pre-flight inspection.
  • Registered via register_domain so ha.vacuum("roborock") works automatically. Exported from haclient.domains.

NumPy-style docstrings throughout, per AGENTS.md.

Tests / checks

Added tests/test_domains.py cases:

  • test_vacuum_actions_full_featured — every action dispatches the right service against a fully-featured vacuum.
  • test_vacuum_send_command_without_paramssend_command omits params when none provided.
  • test_vacuum_unsupported_features_are_noops — actions degrade safely with missing/invalid supported_features.
  • test_vacuum_state_props — state convenience properties and attribute coercion (including malformed inputs).
  • test_vacuum_listenerson_start/on_dock/on_error/on_battery_change/on_fan_speed_change fire on the relevant transitions.

Validation suite:

  • pytest tests/ --cov=haclient --cov-report=term-missing --cov-fail-under=95270 passed, total coverage 96.84%, vacuum.py at 100%.
  • ruff check src tests — clean.
  • ruff format --check src tests — clean.
  • mypy src — clean (strict mode, 35 files).

Adds typed Vacuum entity wrapper exposing intent-specific actions
(start, pause, stop, return_to_base, locate, clean_spot,
set_fan_speed, send_command) and structured state introspection
(is_cleaning/is_docked/is_idle/is_paused/is_returning/is_error,
battery_level, fan_speed, fan_speed_list) instead of raw service
calls. Optional capabilities degrade safely based on the
VacuumEntityFeature bitmask, with supports_* properties for
pre-checking. Listener decorators: on_start, on_dock, on_error,
on_battery_change, on_fan_speed_change.
@Faerkeren Faerkeren merged commit 97f8ce1 into main May 26, 2026
12 checks passed
@Faerkeren Faerkeren deleted the feature/vacuum-domain branch May 26, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Vacuum domain support

1 participant